package org.dearsoft.keepleaping.seam.example.dvdstore.accountdeposits;

import java.io.Serializable;

import javax.ejb.Remove;
import javax.ejb.Stateful;

import org.dearsoft.keepleaping.seam.example.dvdstore.accountdeposits.Record.Status;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.bpm.BeginTask;
import org.jboss.seam.annotations.bpm.EndTask;

@Stateful(name = "accountdeposits/AcceptAction")
@Name("org.dearsoft.keepleaping.seam.example.dvdstore.accountdeposits.accept")
@Scope(ScopeType.CONVERSATION)
public class AcceptAction implements Accept, Serializable {
	
	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = -225907464873394788L;
	
	@In
	private Record record;
	
	/* (non-Javadoc)
	 * @see org.dearsoft.keepleaping.seam.example.dvdstore.accountdeposits.Accept#review()
	 */
	@BeginTask
	public String review() {
		record.setStatus(Status.PROCESSING);
		return "accept";
	}
	
	/* (non-Javadoc)
	 * @see org.dearsoft.keepleaping.seam.example.dvdstore.accountdeposits.Accept#reject()
	 */
	@EndTask(transition = "reject")
	public String reject() {
		record.setStatus(Status.REJECTED);
		return "admin";
	}

	/* (non-Javadoc)
	 * @see org.dearsoft.keepleaping.seam.example.dvdstore.accountdeposits.Accept#accept()
	 */
	@EndTask(transition = "accept")
	public String accept() {
		record.setStatus(Status.ACCEPTED);
		return "admin";
	}

	@Remove
	public void destroy() {	
	}

}
